<?php

/**
 * @author      :   Nhanva
 * @name        :   Thethao_Business_Author
 * @copyright   :   Fpt Online
 * @todo        :   Block business
 */
class Fpt_Business_Author_Adapter_MySql extends Fpt_Business_Author_Adapter_Abstract {

    protected static $_instance = null;

    /**
     * Constructor of class
     * we don't permit an explicit call of the constructor! (like $v = new Singleton())
     */
    public function __construct() {
        
    }

    /**
     * Get singletom instance
     * @return <object>
     */
    public final static function getInstance() {
        //Check instance
        if (is_null(self::$_instance)) {
            self::$_instance = new self();
        }

        //Return instance
        return self::$_instance;
    }

    /**
     * Get author info detail
     * @param int $intAuthorID
     * @return <array> Author information 
     */
    public function getDetailAuthor($intAuthorID) {
        try {
            $sport_m = Fpt_Global::getSportDB();
            // Get user activeation key
            $objStmt = $sport_m->prepare('CALL sp_getDetailUser(:p_userid)');

            // Bind param
            $objStmt->bindParam('p_userid', $intAuthorID, PDO::PARAM_INT);

            // Fetch result
            $objStmt->execute();
            $arrAuthoInfo = $objStmt->fetch();

            // Close cursor
            $objStmt->closeCursor();

            // Release
            unset($objStmt);
        } catch (Zend_Db_Exception $ex) {
            //log error
            Fpt_Log::sendlog(4, $ex->getCode(), $ex->getMessage(), $ex->getTraceAsString(), null, null);
            return false;
        }
        return $arrAuthoInfo;
    }

}